package com.bjdd.jdy.ui.register;

import com.bjdd.jdy.base.BaseResult;
import com.bjdd.jdy.entity.TokenResult;
import com.bjdd.jdy.entity.User;
import com.bjdd.jdy.util.Api;
import com.bjdd.jdy.util.RxSchedulers;


import rx.Observable;

/**
 * Created by shq1 on 2017/4/2.
 */

public class RegisterModel implements RegisterContract.Model {
    @Override
    public Observable<BaseResult<TokenResult>> getRegisterModel(String phone, String pwd, String code, String time, String sign) {
        return Api.getInstance().service
                .register(phone,pwd,code,time,sign)
                .compose(RxSchedulers.io_main());

    }

    @Override
    public Observable<BaseResult<String>> getCodeModel(String mobile,String timestamp,String sign) {
        return Api.getInstance().service
                .code(mobile,timestamp,sign)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<User>> getUserInfo(String token, String userId) {
        return Api.getInstance().service
                .getUserInfo(token,userId)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<String>> getResultModel(String mobile, String pwd, String code, String timestamp, String sign) {
        return Api.getInstance().service
                .resetPwd(mobile,pwd,code,timestamp,sign)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<String>> getForgetCodeModel(String mobile, String timestamp, String sign) {
        return Api.getInstance().service
                .getForgetCode(mobile,timestamp,sign)
                .compose(RxSchedulers.io_main());
    }
}
